/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rbh.risk.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 *
 * @author IT-Mafia
 */
@Entity
@XmlRootElement
@Table(name = "rbh_risk_category")
public class Category implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CATEGORY_ID", unique = true, nullable = false, columnDefinition = "smallint UNSIGNED")
    private Short categoryId;
    @Basic(optional = false)
    @Column(name = "CATEGORY_NAME", unique = true, nullable = false, length = 100)
    private String categoryName;
    @Basic(optional = false)
    @Column(name = "CATEGORY_ORDER_NUMBER", columnDefinition = "tinyint UNSIGNED default 0", nullable = false)
    private short categoryOrderNumber;
    @Basic(optional = false)
    @Column(name = "CATEGORY_STATUS", columnDefinition = "boolean default true", nullable = false)
    private boolean categoryStatus;
    @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<MainEvent> mainEventList;
    @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<SeverityLevelDetail> severityLevelDetailList;
    @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<RiskData> riskDataList;

    public Category() {
    }

    public Category(Short categoryId) {
        this.categoryId = categoryId;
    }

    public Category(Short categoryId, String categoryName, short categoryOrderNumber, boolean categoryStatus) {
        this.categoryId = categoryId;
        this.categoryName = categoryName;
        this.categoryOrderNumber = categoryOrderNumber;
        this.categoryStatus = categoryStatus;
    }

    public Short getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Short categoryId) {
        this.categoryId = categoryId;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public short getCategoryOrderNumber() {
        return categoryOrderNumber;
    }

    public void setCategoryOrderNumber(short categoryOrderNumber) {
        this.categoryOrderNumber = categoryOrderNumber;
    }

    public boolean getCategoryStatus() {
        return categoryStatus;
    }

    public void setCategoryStatus(boolean categoryStatus) {
        this.categoryStatus = categoryStatus;
    }

    @XmlTransient
    public List<MainEvent> getMainEventList() {
        return mainEventList;
    }

    public void setMainEventList(List<MainEvent> mainEventList) {
        this.mainEventList = mainEventList;
    }

    @XmlTransient
    public List<RiskData> getRiskDataList() {
        return riskDataList;
    }

    public void setRiskDataList(List<RiskData> riskDataList) {
        this.riskDataList = riskDataList;
    }

    public List<SeverityLevelDetail> getSeverityLevelDetailList() {
        return severityLevelDetailList;
    }

    public void setSeverityLevelDetailList(List<SeverityLevelDetail> severityLevelDetailList) {
        this.severityLevelDetailList = severityLevelDetailList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (categoryId != null ? categoryId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Category)) {
            return false;
        }
        Category other = (Category) object;
        if ((this.categoryId == null && other.categoryId != null) || (this.categoryId != null && !this.categoryId.equals(other.categoryId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rbh.risk.entity.Category[ categoryId=" + categoryId + " ]";
    }
}
